import VueRouter from "vue-router";
import Vue from "vue";
import login from "@/views/login/login.vue";
import chart from "@/views/layout/chart/chart.vue";
import layout from "@/views/layout/layout.vue";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import question from "@/views/layout/question/question.vue";
import business from "@/views/layout/business/business.vue";
import subject from "@/views/layout/subject/subject.vue";
import user from "@/views/layout/user/user.vue";

Vue.use(ElementUI);

Vue.use(VueRouter);
const router = new VueRouter({
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: login,
    },
    {
      path: "/layout",
      component: layout,
      redirect: "/layout/chart",
      children:[
        {
          path: "/layout",
          redirect: "/layout/chart",
          
        },
        {
          path: "/layout/chart",
          component: chart,
          meta:{
            title:'数据概览'
          }
        },
        {
          path: "/layout/question",
          component: question,
          meta:{
            title:'题库列表'
          }
        },
        {
          path: "/layout/business",
          component: business,
          meta:{
            title:'企业列表'
          }
        },
        {
          path: "/layout/subject",
          component: subject,
          meta:{
            title:'学科列表'
          }
        },
        {
          path: "/layout/user",
          component: user,
          meta:{
            title:'用户列表'
          }
        }
      ]
    },
  ],
});
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
router.beforeEach((to,from,next)=>{
  Nprogress.start()
  next()
})
router.afterEach((to,from)=>{
  Nprogress.done()
  window.console.log('to',to)
  window.console.log('from',from)
  document.title=to.meta.title
})
export default router;
